<template>
    <div class="">
        <mt-header fixed title="vue移动例子"></mt-header>
       <transition name="router" mode="out-in">
           <router-view></router-view>
       </transition>
        <nav class="mui-bar mui-bar-tab">
            <router-link class="mui-tab-item" to="/home">
                <span class="mui-icon mui-icon-home"></span>
                <span class="mui-tab-label">首页</span>
            </router-link>
            <router-link class="mui-tab-item" :to="{name:'huiyuan'}">
                <span class="mui-icon icon-huiyuan"></span>
                <span class="mui-tab-label">会员</span>
            </router-link>
            <router-link class="mui-tab-item" to="/car">
                <span class="mui-icon icon-gouwuchekong"><span class="mui-badge">{{sum}}</span></span>
                <span class="mui-tab-label">购物车</span>
            </router-link>
            <router-link class="mui-tab-item" to="search">
                <span class="mui-icon mui-icon-search"></span>
                <span class="mui-tab-label">搜索</span>
            </router-link>
        </nav>
    </div>
</template>

<script >
    import connect from "./components/connect";
    import prodTools from "./components/prodTools";
    export default {
        data(){
            return{
                sum:prodTools.getAll()
            }
        },
        created() {
            connect.$on("sum",num=>{
                this.sum+=num;
            })
        }
    }
</script>

<style scoped lang="less">
    .router-enter-active,.router-leave-active {
        transition: opacity .1s;
    }
    .router-enter,.router-leave-to {
        opacity: 0;
    }
</style>